<%var jstpl = {%>
    <script>
        var app = new Vue({
            el: "#gexin_body",
            data: {
                query: {
                    news_id: '${news_id!}' ? '${news_id!}' : 0,
                    title: "",
                    state: "",
                    type_id: "",
                    pageNumber: 1,
                    pageSize: 10
                },
                data_result: []
            },
            created: function() {
                this.loadPage("init")
            },
            methods: {
                loadPage: function(model) { //载入模式有两种  init初始化载入 load分页载入
                    if (model == "init") {
                        this.query.pageNumber = 1;
                    }
                    Ajax("/system/notice/loadCommentNewsData", this.query, function(d) {
                        if (!d.state) {
                            gx.alert(d.msg);
                            return false;
                        }
                        if (d.data.list == null || d.data.list.size <= 0 || d.data == null) {
                            app.query.pageNumber = 1;
                            app.data_result = [];
                            return false;
                        }
                        app.data_result = d.data.list;
                        if (d.data.firstPage == true) {
                            layui.laypage.render({
                                elem: 'gexin_page' //注意，这里的 test1 是 ID，不用加 # 号
                                    ,
                                layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
                                count: d.data.totalRow //数据总数，从服务端得到
                                    ,
                                limit: app.query.pageSize,
                                jump: function(obj, first) {
                                    app.query.pageNumber = obj.curr;
                                    if (app.query.pageSize != obj.limit) {
                                        app.query.pageSize = obj.limit;
                                        app.loadPage("init");
                                        return;
                                    }
                                    if (!first) {
                                        app.loadPage("load");
                                    }
                                }
                            });
                        }
                    })
                },
                selectImg: function(img) {
                    gx.photos('封面图', img);
                }
            }
        })
    </script>
    <%};%>
        <%var csstpl = {%>
            <style type="text/css">
                [v-cloak] {
                    display: none
                }
            </style>
            <%};%>
                <%layout("../layout/_layout_layui.html",{title:'公告管理',jstpl:jstpl,csstpl:csstpl}){ %>
                    <div class="layui-row" v-cloak>
                        <div class="layui-col-md12">
                            <div class="layui-col-md3">
                                <div class="layui-form-item ">
                                    <label class="layui-form-label">关键字</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="title" v-model="query.title" placeholder="请输入评论内容" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>

                            <div class="layui-col-md3">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">状态</label>
                                    <div class="layui-input-block">
                                        <select class="layui-input" v-model="query.state">
                        <option value="">请选择状态</option>
                        <option value="0">正常</option>
                        <option value="1">禁用</option>
                    </select>
                                    </div>
                                </div>
                            </div>

                            <div class="layui-col-md3">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <div class="layui-input-block">
                                            <button type="button" @click="loadPage('init')" class="layui-btn ">查询</button>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>

                        <div class="layui-col-md12" style="margin-top: 20px">
                            <table class="layui-table">
                                <thead>
                                    <tr>
                                        <th>序号</th>
                                        <th>资讯标题</th>
                                        <th>评论内容</th>
                                        <th>评论用户</th>
                                        <th>评论时间</th>
                                        <th>点赞数量</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="tbody_body">
                                    <tr v-for="d  in  data_result">
                                        <td>{{d.id}}</td>
                                        <td>{{d.title}}</td>
                                        <td>{{d.content}}</td>
                                        <td>{{d.nickname}}</td>
                                        <td>{{d.create_time}}</td>
                                        <td>{{d.like_count}}</td>
                                        <td class="action-col">
                                            <div class="layui-btn-group">
                                                <!-- <a class="layui-btn layui-btn-primary layui-btn-sm" :href="'/system/notice/addPlacard/'+d.id">修改</a> -->
                                                <a class="layui-btn layui-btn-primary layui-btn-sm" :href="'javascript:gx.del(\'/system/notice/deleteComment/'+d.id+'\')'">删除</a>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr v-if="data_result.length==0">
                                        <td colspan="7" style="text-align:center;height:300px">
                                            <h1>没有数据</h1>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <fieldset id="gexin_page" class="layui-elem-field layui-field-title">
                            </fieldset>
                        </div>
                    </div>
                    <%};%>